<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class previous_event_model extends MY_Model {
	
	protected $table = "previous_event";
	protected $key			= "id";
	protected $soft_deletes	= true;
	protected $date_format	= "datetime";
	protected $set_created	= false;
	protected $set_modified = false;
	
	protected $orderby = 'event_start';
	

	
	function find($id='')
	{
		//parent::set_selects();
		
		//check if the contact has company
		// if yes do the join else skip join
		
		$this->db->select('previous_event.*, contacts.name_ar, contacts.name_en, company.name as com');
		$this->db->join('company', 'company.id = previous_event.company_id');
		$this->db->join('contacts', 'contacts.id = previous_event.contact_id');
		
		$query = $this->db->get_where($this->table, array($this->table.'.'. $this->key => $id));
		//print_r($this->db->last_query());
		if ($query->num_rows())
		{
			return $query->row();
		}
		
		return false;
	}
}
